@extends('master')


@section('title','您的订单')

@section('content')

xxxxxxxx

@endsection

@section('my-js')
<script type="text/javascript">
	$('.bk_validate_code').click(function(){
		$(this).attr('src','/service/validate_code/create?random='+Math.random());
	})
    function onLoginClick(){
                var username = '';
                var password = '';
                var validate_code = '';
                username = $('input[name=username]').val();
                password = $('input[name=password]').val();
                validate_code = $('input[name=validate_code]').val();

                if(validate_code.length<4){
                    $('.bk_toptips').show();
                    $('.bk_toptips span').html('验证码为4位');
                    setTimeout(function () {
                        $('.bk_toptips').hide();
                    }, 2000);
                    return;
                }

        $.ajax({
            type: "POST",
            url: '/service/login',
            dataType: 'json',
            cache: false,
            data: {
                username: username,
                password: password,
                validate_code: validate_code,
                _token: "{{csrf_token()}}"
            },
            success: function (data) {
                if (data == null) {
                    $('.bk_toptips').show();
                    $('.bk_toptips span').html('服务端错误');
                    setTimeout(function () {
                        $('.bk_toptips').hide();
                    }, 2000);
                    return;
                }
                if (data.status != 0) {
                    $('.bk_toptips').show();
                    $('.bk_toptips span').html(data.message);
                    setTimeout(function () {
                        $('.bk_toptips').hide();
                    }, 2000);
                    return;
                }

                $('.bk_toptips').show();
                $('.bk_toptips span').html('登录成功');
                setTimeout(function () {
                    $('.bk_toptips').hide();
                }, 2000);

                location.href='/category';
            },
            error: function (xhr, status, error) {
                console.log(xhr);
                console.log(status);
                console.log(error);
            }
        });
	}




</script>
@endsection






